package com.xiaoke.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xiaoke.domain.ResponseResult;
import com.xiaoke.domain.entity.Tag;
import com.xiaoke.domain.vo.GetTagList;
import com.xiaoke.mapper.TagMapper;
import com.xiaoke.service.TagService;
import com.xiaoke.utils.BeanCopyUtils;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.xiaoke.constants.SystemConstants.STATUS_NORMAL;

/**
 * 标签表(Tag)表服务实现类
 *
 * @author xiaoke
 * @since 2023-03-16 23:05:43
 */
@Service("tagService")
public class TagServiceImpl extends ServiceImpl<TagMapper, Tag> implements TagService {

    @Override
    public ResponseResult getTagList() {
        LambdaQueryWrapper<Tag> queryWrapper = new LambdaQueryWrapper<>();

        queryWrapper.eq(Tag::getStatus,STATUS_NORMAL);

        List<Tag>  tagList = list(queryWrapper);

        List<GetTagList> getTagLists = BeanCopyUtils.copyBeanList(tagList, GetTagList.class);

        return ResponseResult.okResult(getTagLists);
    }
}

